package com.test.project.system.pingfen.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.test.framework.aspectj.lang.enums.BusinessType;
import com.test.project.system.pingfen.domain.TPingfen;
import com.test.project.system.pingfen.service.ITPingfenService;
import com.test.framework.web.controller.BaseController;
import com.test.framework.web.domain.AjaxResult;
import com.test.common.utils.poi.ExcelUtil;
import com.test.framework.web.page.TableDataInfo;

/**
 * 评委评分Controller
 * 
 * @author test
 * @date 2023-12-05
 */
@Controller
@RequestMapping("/system/pingfen")
public class TPingfenController extends BaseController
{
    private String prefix = "system/pingfen";

    @Autowired
    private ITPingfenService tPingfenService;

    @GetMapping()
    public String pingfen()
    {
        return prefix + "/pingfen";
    }

    /**
     * 查询评委评分列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TPingfen tPingfen)
    {
        startPage();
        List<TPingfen> list = tPingfenService.selectTPingfenList(tPingfen);
        return getDataTable(list);
    }

    /**
     * 导出评委评分列表
     */
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TPingfen tPingfen)
    {
        List<TPingfen> list = tPingfenService.selectTPingfenList(tPingfen);
        ExcelUtil<TPingfen> util = new ExcelUtil<TPingfen>(TPingfen.class);
        return util.exportExcel(list, "pingfen");
    }

    /**
     * 新增评委评分
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存评委评分
     */
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TPingfen tPingfen)
    {
        return toAjax(tPingfenService.insertTPingfen(tPingfen));
    }

    /**
     * 修改评委评分
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TPingfen tPingfen = tPingfenService.selectTPingfenById(id);
        mmap.put("tPingfen", tPingfen);
        return prefix + "/edit";
    }

    /**
     * 修改保存评委评分
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TPingfen tPingfen)
    {
        return toAjax(tPingfenService.updateTPingfen(tPingfen));
    }

    /**
     * 删除评委评分
     */
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tPingfenService.deleteTPingfenByIds(ids));
    }
}
